#ifndef __ASM_AARM_IRQFLAGS_H__
#define __ASM_ARM_IRQFLAGS_H__

static inline void arch_enable_irq(void)
{
  __asm__(
      "mrs r0, cpsr\n"
      "bic r0, r0, #0x80\n"
      "msr cpsr_cxsf, r0\n"
      :
      :
      : "r0");
}

static inline void arch_disable_irq(void)
{
  __asm__(
      "mrs r0, cpsr\n"
      "orr r0, r0, #0x80\n"
      "msr cpsr_cxsf, r0\n"
      :
      :
      : "r0");
}

static inline unsigned long arch_local_irq_save(void)
{
  unsigned long flags = 0;

  __asm__ __volatile__(
      "mrs r1, cpsr\n"
      "mov %0, r1\n"
      "orr r1, r1, #0x80\n"
      "msr cpsr_cxsf, r1\n"
      : "=r"(flags)
      :
      : "r1");

  return flags;
}

static inline unsigned long arch_local_save_flags(void)
{
  unsigned long cp;

  __asm__(
      "mrs %0, cpsr\n"
      : "=r"(cp));

  return cp;
}

static inline void arch_local_irq_restore(unsigned int flags)
{
  __asm__(
      "msr cpsr_cxsf, %0\n"
      :
      : "r"(flags));
}


#endif
